<?php
namespace App\Http\Controllers\User;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\DB;
use App\Models\ToolCabinetModel;

class ToolCabinetController extends Controller{

    public function __construct()
    {
        $this->middleware('user_login');
    }

    /**
     * 研学工具箱
     */
    public function tool_cabinet(Request $request,ToolCabinetModel $toolCabinetModel){

        $query = $toolCabinetModel->select(['id','content','country','city','country_id','city_id','title']);

        $country_id = $request->input('country_id');
        if(empty($country_id)){
            return returnMsg(400,'国家必选');
        }
        $query->where('country_id',$country_id);

      /*  $city_id = $request->input('city_id');
        if(!empty($city_id)){
            $query->where('city_id',$city_id);
        }*/

        $data = $query->get()->toArray();

       $data['title_array'] = array_column($data, 'title');

        return returnMsg(0,'获取成功',$data);
    }

}